//
//  OtherController.m
//  LazyCat
//
//  Created by jike on 15/12/28.
//  Copyright (c) 2015年 zhanshu. All rights reserved.
//

#import "OtherController.h"
#import "OtherTableCell.h"
#import "dpglViewController.h"
#import "ClassifyManageViewController.h"
#import "WebViewController.h"
#import "CaiWuManageViewController.h"
#import "clientViewController.h"
#import "expressViewController.h"
#import "serverViewController.h"
#import "detailWebViewController.h"

@interface OtherController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, retain) UITableView *tableView;

@end

@implementation OtherController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initNav:@"其他" doBack:YES];
    [self createTable];
}
-(void)createTable {
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 63, ScreenWidth, ScreenHeight - 64) style:UITableViewStyleGrouped];
    self.tableView.rowHeight = 50;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.scrollEnabled = NO;
    [self.view addSubview:self.tableView];
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0.001;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 5;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *Cell = @"cell";
    OtherTableCell *cell = [tableView dequeueReusableCellWithIdentifier:Cell];
    if (!cell) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"OtherTableCell" owner:self options:nil] firstObject];
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    NSArray *titleArr = @[@"数据统计",@"财务管理",@"优惠券",@"客户管理",@"快递服务"];
    NSArray *imgArr = @[@"qt1",@"qt2",@"qt3",@"qt4",@"kuaidi"];
    cell.titleLable.text = titleArr[indexPath.row];
    cell.img.image = [UIImage imageNamed:imgArr[indexPath.row]];
    cell.titleLable.font = [UIFont systemFontOfSize:14];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) { // 数据统计
        detailWebViewController *detailWebVC = [[detailWebViewController alloc]init];
        [self.navigationController pushViewController:detailWebVC animated:YES];
    }else if (indexPath.row == 1){ // 财务管理
        CaiWuManageViewController *caiwu = [[CaiWuManageViewController alloc] init];
        [self.navigationController pushViewController:caiwu animated:YES];
    }else if (indexPath.row == 2){ // 营销工具
        dpglViewController *dpgl = [[dpglViewController alloc] init];
        [self.navigationController pushViewController:dpgl animated:YES];
    }else if (indexPath.row == 3){ // 客户管理
        serverViewController *clientVC = [[serverViewController alloc]init];
        NSUserDefaults *userDefaul = [NSUserDefaults standardUserDefaults];
        NSString *iptype = [userDefaul objectForKey:@"iptype"];
        NSString *banben = [userDefaul objectForKey:@"banben"];
        NSString *url = [NSString stringWithFormat:serverManagerUrl,[AppData share].username,[Utils md5SignStr],iptype,banben];
        clientVC.requestUrl = url;
        [self.navigationController pushViewController:clientVC animated:YES];
    }else if (indexPath.row == 4) { // 快递服务
        expressViewController *clientVC = [[expressViewController alloc]init];
        NSUserDefaults *userDefaul = [NSUserDefaults standardUserDefaults];
        NSString *iptype = [userDefaul objectForKey:@"iptype"];
        NSString *banben = [userDefaul objectForKey:@"banben"];
        NSString *url = [NSString stringWithFormat:KDManagerUrl,[AppData share].username,[Utils md5SignStr],iptype,banben];
        clientVC.requestUr = url;
        [self.navigationController pushViewController:clientVC animated:YES];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}
@end
